const mongoose = require('mongoose');

// 构建评论模型
const Schema = mongoose.Schema;
const commentsChildrenSchema = new Schema({
    content: {
        type: String,
        require: true
    },
    auth: { // 评论者
        type: Schema.Types.ObjectId,
        ref: 'user',
        require: true,
        default: null
    },
    parent_id: { // 父评论
        type: Schema.Types.ObjectId,
        ref: 'comments',
        require: true,
        default: null
    },
    parent_auth: { // 父评论作者
        type: Schema.Types.ObjectId,
        ref: 'comments',
        default: null
    },
    reply: { // 被@的人
        type: Schema.Types.ObjectId,
        ref: 'user',
        default: null
    },
    createDate: {
        type: Date,
        default: Date.now
    },
    upDate: {
        type: Date,
        default: Date.now
    },
    delete: {
        type: Boolean,
        default: false
    }
});

module.exports = mongoose.model('comments_children', commentsChildrenSchema);
